//事件上报
saveUserInfo(); //第一个页面调用该方法缓存用户名头像
var vm = new Vue({
	el: '#app',
	data: function() {
		return {
			defaultData: {
				one: 71938.97,
				two: 57466.45,
				three: 64230.81
			},
			datas: {
				"TOTAL": 200162.2906,
				"THIRD": 39595.492,
				"FIRST_V": 52286.5325,
				"SECOND_V": 33448.2661
			}

		}
	},
	mounted: function() {
		var that = this;
		that.getData(); //请求数据
		mui.init();
		mui.previewImage();
		mui.ready(function() {
			mui('.mui-scroll-wrapper').scroll({
				deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
			});
			$('.link').on('tap', function() {
				var href = $(this).data('href');
				location.href = href;
			})
			var gallery = mui('.mui-slider');
			gallery.slider({
				interval: 3000 //自动轮播周期，若为0则不自动播放，默认为0；
			});
			$('.toggle-nav').on('tap', function() {
				mui('.mui-off-canvas-wrap').offCanvas('show');
			});
		})
	},
	computed: {
		onePercent: function() {
			var that = this;
			return((that.datas.FIRST_V / that.defaultData.one) * 100).toFixed(2);
		},
		twoPercent: function() {
			var that = this;
			return((that.datas.SECOND_V / that.defaultData.two) * 100).toFixed(2);
		},
		threePercent: function() {
			var that = this;
			return((that.datas.THIRD / that.defaultData.three) * 100).toFixed(2);
		},
		totalPercent: function() {
			var that = this;
			return((that.datas.TOTAL / 375917) * 100).toFixed(2);
		}
	},
	methods: {
		//请求数据方法
		getData: function() {
			var that = this;
			loading.show();
			$.getJSON('getMolecular', {}, function(res) {
				that.datas = res;
				loading.hide()
			})
		}
	}
})